<?php
/**
 * Created by PhpStorm.
 * User: chengyu
 * Date: 2021/6/7 0007
 * Time: 19:45
 */

namespace app\api\controller\v1;

use app\BaseController;
use app\common\model\Banner;
use app\common\model\Cate;
use app\common\model\Driver as DriverModel;

class Driver extends BaseController
{
    //获取司机报名
    //程宇
    public function index()
    {
        return sucessMsg('200', '获取成功', [
            'banner' => $this->banner(),//获取banner
            'tag' => $this->tag(),//获取banner图上标签
            'content1' => $this->content1(),//获取农副网司机要求
            'content2' => $this->content2(),//获取农副网司机福利
            'content3' => $this->content3(),//获取农副网招募流程
        ]);
    }

    //获取banner
    public function banner()
    {
        $model = New Banner();
        $banner = $model->where(['status' => 1, 'type' => 8])
            ->field('id,title,image')
            ->order('sort', 'asc')
            ->select();
        foreach ($banner as $v) {
            $v['image'] = env('app.yuming') . $v['image'];
        }
        return $banner;
    }

    /**
     * 获取首页banner标签
     */
    public function tag()
    {
        $model = New Cate();
        $type = [1, 2, 3];
        $tag = $model->where('status', 1)
            ->where('type', 'in', $type)
            ->field('id,name,image')
            ->select();
        foreach ($tag as $v) {
            $v['image'] = env('app.yuming') . $v['image'];
        }
        return $tag;
    }

    //获取农副网司机要求
    public function content1()
    {
        $model = New DriverModel();
        $content1 = $model->where(['status' => 1, 'type' => 1])
            ->field('id,title,content,image')
            ->select();
        foreach ($content1 as $v) {
            $v['image'] = env('app.yuming') . $v['image'];
        }
        return $content1;
    }

    //获取农副网司机福利
    public function content2()
    {
        $model = New DriverModel();
        $content2 = $model->where(['status' => 1, 'type' => 2])
            ->field('id,title,content,image')
            ->select();
        foreach ($content2 as $v) {
            $v['image'] = env('app.yuming') . $v['image'];
        }
        return $content2;
    }

    //获取农副网招募流程
    public function content3()
    {
        $model = New DriverModel();
        $content3 = $model->where(['status' => 1, 'type' => 3])
            ->field('id,title,content,image')
            ->select();
        foreach ($content3 as $v) {
            $v['image'] = env('app.yuming') . $v['image'];
        }
        return $content3;
    }
}